package com.hellpro.lolbox.video.model;

import android.content.Context;
import android.widget.ListView;
import android.widget.Toast;

import com.handmark.pulltorefresh.library.PullToRefreshBase;
import com.handmark.pulltorefresh.library.PullToRefreshBase.OnRefreshListener;
import com.handmark.pulltorefresh.library.PullToRefreshListView;
import com.hellpro.lolbox.video.bean.VideoManitoBean;

import java.util.List;

/**
 * 类描述:
 * 创建人:阿犇
 * 创建时间:2016/10/20
 * 备注:
 */

public class ManitoBiz implements IManitoInfo{


    /**
     *
     * 类描述:
     * 创建人:阿犇
     * 创建时间:2016/10/20
     * 备注:设置大神直播间的适配器
     */

    @Override
    public void setVideoRefreshLvAdapter(List<VideoManitoBean> data, final PullToRefreshListView mLv, final Context context) {
        VideoManitoLvAdapter adapter = new VideoManitoLvAdapter();
        //设置是否允许刷新的时候滚动屏幕
        mLv.setShowViewWhileRefreshing(true);
        //设置下拉模式为下拉
        mLv.setMode(PullToRefreshBase.Mode.PULL_FROM_START);
        adapter.setData(data);
        mLv.setAdapter(adapter);
        mLv.setOnRefreshListener(new OnRefreshListener<ListView>() {
            @Override
            public void onRefresh(PullToRefreshBase<ListView> refreshView) {
                Toast.makeText(context, "没有更多数据", Toast.LENGTH_SHORT).show();
                //设置下拉刷新的延迟时间，时间太短刷新图标无法隐藏
                mLv.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        mLv.onRefreshComplete();
                    }
                }, 1000);
            }
        });
    }
}
